package com.metro.activation.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@EnableWebMvc
@ComponentScan(basePackages = {"com.metro.activation.app.controller"})  //需要扫描的包路径
public class SwaggerConfig extends WebMvcConfigurationSupport{
	
	
	 @Bean
	    public Docket swaggerSpringMvcPlugin() {
	        return new Docket(DocumentationType.SWAGGER_2)
	                .apiInfo(apiInfo())
	                .groupName("business-api")
	                .select()   // 选择那些路径和api会生成document
                	.apis(RequestHandlerSelectors.basePackage("com.metro.activation.app.controller"))
	                .paths(PathSelectors.any())   // 对所有路径进行监控
	                .build();
	    }
	
	
	private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("NDS盒子 客户端、PAD激活平台 API")
                .termsOfServiceUrl("http://www.qsign.cn")
                .description("此API提供接口调用")
                .license("NDS Version 1.0")
                .licenseUrl("http://www.qsign.cn")
                .version("1.0").build();
    }
	
}
